home *** CD-ROM | disk | FTP | other *** search
- /*
- * count-paths.h: Declarations for count-paths.c
- *
- * Copyright (C) 1992, William F. Galway
- *
- * Anyone can do what they like with this code, as long as they
- * acknowledge its author, and include this message in their code.
- */
-
- typedef int BOOL;
-
- #define TRUE 1
- #define FALSE 0
-
- /* Possible target systems/compilers... */
- #define ThinkC 0
- #define GnUnix 1
-
- #if !defined(TARGET)
- #define TARGET ThinkC
- #endif
-
- #if !defined(DEBUG)
- #define DEBUG FALSE
- #endif
-
- #if !defined(VERBOSE)
- #define VERBOSE FALSE
- #endif
-
- /* Maximum allowable dimensions of the "matrix". */
- #define MAXORDER 10
-
- #if (TARGET==GnUnix)
- /* This is the "Mac" StringPtr type. The first byte gives the length, */
- /* the rest of the bytes make up the string. */
- typedef unsigned char Str255[256], *StringPtr;
-
- /* Native is the type most naturally addressed, roughly speaking... */
- typedef void Native;
- #endif
-
- #if (TARGET==ThinkC)
- /* Native is the type most naturally addressed, roughly speaking... */
- typedef char Native;
- #endif
-
- typedef struct locnode {
- /* Next node in list for a given character. */
- struct locnode *next;
- } LocNode;
-
- typedef struct {
- /* Number of entries per row... */
- long dy;
- /* Vector of LocNodes indexed by character code, giving first location */
- /* of character. */
- LocNode char_index[256];
- /* "Matrix" of LocNodes giving further locations of each character. */
- LocNode index_matrix[(2+MAXORDER)*(2+MAXORDER)];
- } Index;
-
- /* BuildIndex builds up index for matrix of given order. */
- void BuildIndex(long order, const char *matrix, Index *index);
-
- /* count_paths counts paths using previously built index. */
- long count_paths(const Index *index, const StringPtr word);
-
- /* CountPaths is the "top level" path counting routine. */
- long CountPaths(short order, char *matrix, const StringPtr inputWordPtr);
-
-
-